package fatworm.query;

import fatworm.storage.table.*;

public class GroupByPlan implements Plan {
	
	private Plan p;
	private String fieldname;
	private String cmd, name;
	private Predicate pred;
	
	public GroupByPlan(Plan p, String fieldname, String cmd, String name, Predicate pred) {
		this.p = p;
		this.fieldname = fieldname;
		this.cmd = cmd;
		this.name = name;
		this.pred = pred;
	}
	
	public Scan open() {
		return new GroupByScan(p.open(), fieldname, cmd, name, pred);
	}
	
	public int blocksAccessed() {
		return p.blocksAccessed();
	}
	
	public int recordsOutput() {
		return distinctValues(fieldname);
	}
	
	public int distinctValues(String name) {
		return p.distinctValues(name);
	}
	
	public Schema getSchema() {  //TODO
		return p.getSchema();
	}
	
}